#pragma once

namespace MiniHttpServer
{
	ref class IHttpContext;
	public ref class IHttpListener abstract
	{
	public:
		virtual ~IHttpListener() {};

		virtual void Start() = 0;
		virtual void Stop() = 0;
		virtual property bool IsStarted { virtual bool get() = 0; };

		delegate void RequestReceiverDelegate(IHttpContext^ context);

		// Usually, the response should be written in the callback method and the context object should
		// be disposed (directly or indirectly). The context object can be kept however and used in another
		// thread, the request and response objects stay valid until the context object is finally disposed
		virtual void SetRequestReceiver(RequestReceiverDelegate^ handler) = 0;

		static IHttpListener^ Create(System::Net::IPAddress^ ipAddress, int nPort);
	};
};